package com.hemaapp.yjnh.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hemaapp.hm_FrameWork.HemaNetTask;
import com.hemaapp.hm_FrameWork.result.HemaBaseResult;
import com.hemaapp.yjnh.BaseActivity;
import com.hemaapp.yjnh.R;

/**商品详情里常见问题
 * @author ZhangGuiyou
 * Date:2015-8-25 15:19
 */
public class QuestionActivity extends BaseActivity {
	private TextView titleText;
	private ImageButton titleLeft;

	private LinearLayout ll_service;
	private TextView tv_quality;
	private TextView tv_rejected;
	
	private String QQ;
    private String blog_id;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.activity_question);
		super.onCreate(savedInstanceState);
	}

	@Override
	protected void callBeforeDataBack(HemaNetTask netTask) {
	}

	@Override
	protected void callAfterDataBack(HemaNetTask netTask) {
	}

	@Override
	protected void callBackForServerSuccess(HemaNetTask netTask,
			HemaBaseResult baseResult) {
	}

	@Override
	protected void callBackForServerFailed(HemaNetTask netTask,
			HemaBaseResult baseResult) {
	}

	@Override
	protected void callBackForGetDataFailed(HemaNetTask netTask, int failedType) {
	}

	@Override
	protected void findView() {
		titleText = (TextView) findViewById(R.id.title_text);
		titleLeft = (ImageButton) findViewById(R.id.title_left_btn);

		ll_service = (LinearLayout) findViewById(R.id.ll_service);
		tv_quality = (TextView) findViewById(R.id.tv_quality);
		tv_rejected = (TextView) findViewById(R.id.tv_rejected);
	}

	@Override
	protected void setListener() {
		titleText.setText("购买咨询");
		titleLeft.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});
		ll_service.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (QQ != null && !QQ.isEmpty()) {
					String url="mqqwpa://im/chat?chat_type=wpa&uin="+QQ;  
					 startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
				}else {
					showTextDialog("抱歉，暂时没有提供在线咨询服务");
				}
			}
		});
		tv_quality.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent itAbout = new Intent(mContext, WebviewActivity.class);
				itAbout.putExtra("parm", blog_id);
				itAbout.putExtra("type", 1);
				startActivity(itAbout);
			}
		});
		tv_rejected.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent itAbout = new Intent(mContext, WebviewActivity.class);
				itAbout.putExtra("parm", blog_id);
				itAbout.putExtra("type", 2);
				startActivity(itAbout);
			}
		});
	}

	@Override
	protected void getExras() {
        blog_id = mIntent.getStringExtra("blog_id");
        QQ = mIntent.getStringExtra("QQ");
        if (isNull(QQ) || isNull(blog_id)) {
            showTextDialog("数据异常");
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    finish();
                }
            }, 2000);
        }
	}

}
